#ifndef IDC_UBUS_MQTT_H
#define IDC_UBUS_MQTT_H
#include "idc_ubus_common.h"

/**
 * num表示通道号为0，表示控制所有通道，大于0表示控制指定通道
 * val值为0表示关闭，1表示打开；如果
*/
enum {
        SLEEP_TIME,
        WORK_TIME,
        __SLEEP_WAKE_MAX,
} ;
static const struct blobmsg_policy enerty_info_policy[] = {
        [0] = { .name = "addr", .type = BLOBMSG_TYPE_INT32 },
        [1] = { .name = "group_addr", .type = BLOBMSG_TYPE_INT32 },
        [2] = { .name = "trans_addr", .type = BLOBMSG_TYPE_INT32 },
        [3] = { .name = "status", .type = BLOBMSG_TYPE_INT32 },
        [4] = { .name = "batteryVoltage", .type = BLOBMSG_TYPE_INT32 },
        [5] = { .name = "batteryElectric", .type = BLOBMSG_TYPE_INT32 },
        [6] = { .name = "batteryCapacity", .type = BLOBMSG_TYPE_INT32 },
        [7] = { .name = "batteryStatus", .type = BLOBMSG_TYPE_INT32 },
        [8] = { .name = "loadVoltage", .type = BLOBMSG_TYPE_INT32 },
        [9] = { .name = "loadElectric", .type = BLOBMSG_TYPE_INT32 },
        [10] = { .name = "loadPower", .type = BLOBMSG_TYPE_INT32 },
        [11] = { .name = "loadStatus", .type = BLOBMSG_TYPE_INT32 },
        [12] = { .name = "columnVoltage", .type = BLOBMSG_TYPE_INT32 },
        [13] = { .name = "columnStatus", .type = BLOBMSG_TYPE_INT32 },
        [14] = { .name = "runDay", .type = BLOBMSG_TYPE_INT32 },
        [15] = { .name = "lowVolCnt", .type = BLOBMSG_TYPE_INT32 },
        [16] = { .name = "todayDischarge", .type = BLOBMSG_TYPE_INT32 },
        [17] = { .name = "yesterdayDischarge", .type = BLOBMSG_TYPE_INT32 },
        [18] = { .name = "totalDischarge", .type = BLOBMSG_TYPE_INT32 },
        [19] = { .name = "todayCharge", .type = BLOBMSG_TYPE_INT32 },
        [20] = { .name = "yesterdayCharge", .type = BLOBMSG_TYPE_INT32 },
        [21] = { .name = "totalCharge", .type = BLOBMSG_TYPE_INT32 },
        [22] = { .name = "fDevTemperature", .type = BLOBMSG_TYPE_INT32 },
        [23] = { .name = "fBatTemperature", .type = BLOBMSG_TYPE_INT32 },
}; 
static const struct blobmsg_policy send_policy[] = {
        [0] = { .name = "json", .type = BLOBMSG_TYPE_STRING },
}; 
/**
 * 发送电源信息数据到MQTT服务器
 */
int energy_info(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);

int send(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
#endif